#
from typing import Dict
from ultralytics import YOLO

class MiodApp(object):
    def __init__(self):
        self.name = 'apps.miod.miod_app.MiodApp'

    @staticmethod
    def startup(params:Dict = {}) -> None:
        print(f'Yolov12医学图像检测 v0.0.2')
        model = YOLO('./work/ckpts/yolov12n.pt')
        # Train the model
        results = model.train(
            data='datasets/miod/exp01.yaml',
            epochs=600, 
            batch=16, 
            imgsz=640,
            scale=0.5,  # S:0.9; M:0.9; L:0.9; X:0.9
            mosaic=1.0,
            mixup=0.0,  # S:0.05; M:0.15; L:0.15; X:0.2
            copy_paste=0.1,  # S:0.15; M:0.4; L:0.5; X:0.6
            device="cuda:0",
        )
        # Evaluate model performance on the validation set
        metrics = model.val()
        # Perform object detection on an image
        results = model("datasets/miod/train/images/-_mp4-0018_jpg.rf.ac780864d15c1504762738dec3b5a82c.jpg")
        results[0].show()